<div class="g-doc_shuban_new">
	<div class="join_box">
		<?php
		if($this->stop == 1 || $this->maxjoin == 1):
	?>
		<div class="btn2box">
			<form action="/game-joinfromad?share=1" method="post" target="_blank">
			<input type="submit" value="" class="btn2" />
			</form>
		</div>
		<span class="text">
			share your favourite jersey to fans
		</span>
	 <?php
		else:
	 ?>
	 <form action="/game-joinfromad" id="joinfromad_form" method="get" target="_blank">
	<span class="top_text">Join us,and get jerseys for free</span>
	<span class="join_box_c">
			<input type="text" class="input" name="email" id="email" />
			<span class="btn" id="btn1"></span>
		</span>
	<?php endif; ?>
	</form>
	</div>
	<div class="desp">(1) Leave your email and join us.</div>
	<div class="desp p_2">(2) Share jerseys via the &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sharejerseys app.</div>
	<div class="desp p_3"> Click the share button.</div>
	<div class="desp p_4"> Choose the jersey you want to share.</div>
	<div class="desp p_5"> Choose a friend.</div>
	<div class="desp p_6"> Send!</div>
</div>
<script type="text/javascript">
	$(function()
	{
		<?php
			if($this->error_msg == 'You have joined.') {
		?>
			alert('<?php echo $this->error_msg ?> But you can share a jersey to your friends.');
			window.location.href = 'http://apps.facebook.com/sharejersey';
			return false;
		<?php
			}
		?>
		<?php
			if($this->error_msg != '') {
		?>
		alert('<?php echo $this->error_msg ?>');
		//return false;
		<?php
			}
		?>
		$("#btn1").click(function(){
			var email = $("#email").val();
			if(email == '') {
				alert('Sorry, please input the correct email address.');
				return false;
			}
			var exp = new RegExp("^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$", "i");
			if (!exp.test(email)) {
				alert('Sorry, the email is not correct.');
				return false;
			}
			$("#joinfromad_form").submit();
		});
		
		var empty = {},
			fb_settings,
			fb_defaults = {
			init: {
				appId  : '203794096380805',
				status : true, // check login status
				cookie : true, // enable cookies to allow the server to access the session
				xfbml  : true  // parse XFBML
			},
			Canvas: {
				setSize: {
					width: 790,
					height: 1500
				}
			}
		};

		
		if (typeof fb_options === 'undefined') {
			fb_options = {};
		}
		
		fb_settings = $.extend(empty, fb_defaults, fb_options);
		
		FB.init(fb_settings.init);
		FB.Canvas.setSize(fb_settings.Canvas.setSize);
	});
	
</script>